<?php
namespace Core;

/**
 *
 * @author Administrator
 *        
 */
class InputClass
{
    public function get($name,$def=''){
        $value = $this->_getVal($name);
        return  $value?$value:$def;
    }
    public function post($name,$def=''){
        return isset($_POST[$name])?$this->_Sql_Filter($_POST[$name]):$def;
    }
    public function cookie($name){
        return $_COOKIE[$name];
    }
    public function session($name){
        return $_SESSION[$name];
    }
    private function _getVal($name){
        $val = '';
        if(is_string($name)){
            $val = $this->_Sql_Filter($_GET[$name]);
        }else if(is_numeric($name)){
            $val = $this->_Sql_Filter($_GET[iniGet('var_url_params')][$name]);
        } 
        return $val;
    }
    
    private function _Sql_Filter($val)
    {
        if(function_exists('htmlspecialchars')){
            return htmlspecialchars($val);
        }else{
            return $val;
        }
    }
}

?>